﻿@typeparam TItem
@inherits _BaseDataGridRowCommand<TItem>
@if ( EditState == DataGridEditState.Edit )
{
    <TableRowCell Class="@Class" Style="@Style" width="@Width" TextAlignment="@TextAlignment">
        @if ( ParentDataGrid?.CommandColumn?.SaveCommandAllowed == true )
        {
            @if ( ParentDataGrid?.CommandColumn?.SaveCommandTemplate != null )
            {
                @ParentDataGrid.CommandColumn.SaveCommandTemplate( new CommandContext<TItem>
                {
                    Clicked = Save,
                    Item = Item,
                } )
            }
            else
            {
                <Button Color="Color.Link" Clicked="@Save">Save</Button>
            }
        }
        @if ( ParentDataGrid?.CommandColumn?.CancelCommandAllowed == true )
        {
            @if ( ParentDataGrid?.CommandColumn?.CancelCommandTemplate != null )
            {
                @ParentDataGrid.CommandColumn.CancelCommandTemplate( new CommandContext<TItem>
                {
                    Clicked = Cancel,
                    Item = Item,
                } )
            }
            else
            {
                <Button Color="Color.Link" Clicked="@Cancel">Cancel</Button>
            }
        }
    </TableRowCell>
}
else if ( EditState == DataGridEditState.None )
{
    <TableRowCell Class="@Class" Style="@Style" width="@Width" TextAlignment="@TextAlignment">
        @if ( ParentDataGrid?.CommandColumn?.EditCommandAllowed == true )
        {
            @if ( ParentDataGrid?.CommandColumn?.EditCommandTemplate != null )
            {
                @ParentDataGrid.CommandColumn.EditCommandTemplate( new CommandContext<TItem>
                {
                    Clicked = Edit,
                    Item = Item,
                } )
            }
            else
            {
                <Button Color="Color.Link" Clicked="@Edit">Edit</Button>
            }
        }
        @if ( ParentDataGrid?.CommandColumn?.DeleteCommandAllowed == true )
        {
            @if ( ParentDataGrid?.CommandColumn?.DeleteCommandTemplate != null )
            {
                @ParentDataGrid.CommandColumn.DeleteCommandTemplate( new CommandContext<TItem>
                {
                    Clicked = Delete,
                    Item = Item,
                } )
            }
            else
            {
                <Button Color="Color.Link" Clicked="@Delete">Delete</Button>
            }
        }
    </TableRowCell>
}